<?php

namespace app\admin\controller;

use app\admin\model\Wechat as WechatModel;
use app\admin\validate\Wechat as WechatValidate;

class Wechat extends Controller
{
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 获取微信支付配置.
     */
    public function get()
    {
        $model = new WechatModel();
        $type = input('type', 'wechat');

        return $model->get($type);
    }

    /**
     * 编辑微信支付配置.
     */
    public function update()
    {
        $data = input('post.');
        $validate = new WechatValidate();
        if (!$validate->scene('update')->check($data)) {
            return fail($validate->getError());
        }

        $model = new WechatModel();

        return $model->update($data);
    }

    /**
     * 上传支付证书.
     */
    public function uploadCert()
    {
        $model = new WechatModel();

        return $model->uploadCert();
    }
}
